package com.example.springbootlocal.utils.service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;

/**
 * @author X.I.O
 * @title: SessionProvider
 * @projectName demo
 * @description: TODO
 * @date 2021/11/12 11:14
 */
public interface SessionProvider {

    /**
     * 获取session 属性
     * @Title: getAttribute
     * @param request HttpServletRequest
     * @param name 属性名
     * @return: Serializable
     */
    public Serializable getAttribute(HttpServletRequest request, String name);

    /**
     * 设置session 属性
     * @Title: setAttribute
     * @param request HttpServletRequest
     * @param name 属性名
     * @param value  属性值
     * @return: void
     */
    public void setAttribute(HttpServletRequest request,
                             String name, Serializable value);

    /**
     * 获取sessionId
     * @Title: getSessionId
     * @param request HttpServletRequest
     * @return: String
     */
    public String getSessionId(HttpServletRequest request);

    /**
     * 退出 令session失效
     * @Title: logout
     * @param request HttpServletRequest
     * @param response  HttpServletResponse
     * @return: void
     */
    public void logout(HttpServletRequest request, HttpServletResponse response);

    /**
     * 移除属性
     * @Title: removeAttribute
     * @param request HttpServletRequest
     * @param id    属性名
     * @return: void
     */
    public void removeAttribute(HttpServletRequest request, String id);
}
